home *** CD-ROM | disk | FTP | other *** search
/ Magnum One / Magnum One (Mid-American Digital) (Disc Manufacturing).iso / d18 / totdem.arc / DEMLS9.PAS < prev    next >
Pascal/Delphi Source File  |  1991-02-10  |  3KB  |  123 lines

  1. program DemoListNine;
  2. {demls9 - extending the LinkListOBJ object}
  3.  
  4. Uses DOS, CRT,
  5.      totFAST, totLINK, totLIST, totSTR, totMSG;
  6.  
  7. Type
  8.   NewListLinkOBJ = object (ListLinkOBJ)
  9.      {Methods...}
  10.      constructor Init;
  11.      function    MessageTask(HiPick:longint):string;             VIRTUAL;
  12.      function    CharTask(var K:word; var X,Y: byte; 
  13.                           HiPick:longint): tListAction;          VIRTUAL;
  14.      destructor  Done;                                           VIRTUAL;
  15.   end; {NewListLinkOBJ}
  16.  
  17. Var
  18.    ListWin:  NewListLinkObj;
  19.    ItemList: StrDLLOBJ;
  20.    FileOK: boolean;
  21.  
  22. {+++++new object methods+++++}
  23. constructor NewListLinkOBJ.Init;
  24. {}
  25. begin
  26.    ListLinkOBJ.Init;
  27.    vMsgActive := true;
  28.  
  29. end; {NewListLinkOBJ.Init}
  30.  
  31. function  NewListLinkOBJ.MessageTask(HiPick:longint):string;
  32. {}
  33. begin
  34.    MessageTask := 'The Hi Pick is '+IntToStr(HiPick);
  35. end; {NewListLinkOBJ.MessageTask}
  36.  
  37. function NewListLinkOBJ.CharTask(var K:word; var X,Y: byte; 
  38.                                  HiPick:longint): tListAction;     
  39. {}
  40. var MsgWin: MessageOBJ;
  41. begin
  42.    CharTask := none;
  43.    if K = 315 then
  44.    begin
  45.       with MsgWin do
  46.       begin
  47.          Init(6,'Kinda Help');
  48.          AddLine('');
  49.          AddLine('In a real application, this would');
  50.          AddLine('be a help screen, and it would give');
  51.          AddLine('help related to item '+IntToStr(HiPick)+'!');
  52.          AddLine('');
  53.          Show;
  54.          Done;
  55.       end;
  56.       K := 0;
  57.    end
  58.    else if K = 316 then {F2 so swap colors}
  59.    begin
  60.       ListWin.SetStatus(HiPick,1,not ListWin.GetStatus(HiPick,1));
  61.       K := 336; {emulate down cursor}
  62.    end;
  63. end; {NewListLinkOBJ.CharTask}
  64.  
  65. destructor NewListLinkOBJ.Done;
  66. {}
  67. begin
  68.    ListLinkOBJ.Done;
  69. end; {NewListLinkOBJ.Done}
  70. {+++++end of new object methods+++++}
  71.  
  72. procedure LoadLinkedList;
  73. {}
  74. var 
  75.   F: text;
  76.   Line:string;
  77.   Result: integer;
  78. begin
  79.    with ItemList do
  80.    begin
  81.       Init;
  82.       {$I-}
  83.       Assign(F,'demls4.txt');
  84.       Reset(F);
  85.       {$I+}
  86.       FileOK := (IOResult = 0);
  87.       if not FileOK then
  88.          Result := Add('File not found')
  89.       else
  90.       begin
  91.          while not eof(F) do
  92.          begin
  93.             Readln(F,Line);
  94.             Result := Add(Line);
  95.          end;
  96.          close(F);
  97.       end;
  98.    end;
  99. end; {LoadLinkedList}
  100.  
  101. begin
  102.    Screen.Clear(white,'░'); {paint the screen}
  103.    Screen.WriteCenter(25,white,'  F1 Help   F2 Toggle Color!   [Space] Toggle Tag  ');
  104.    LoadLinkedList;
  105.    with ListWin do
  106.    begin
  107.       Init;
  108.       AssignList(ItemList);
  109.       SetColWidth(15);
  110.       SetDualColors(true);
  111.       Win^.SetTitle(' A Multi-Colored List ');
  112.       Win^.SetSize(20,5,60,20,2);
  113.       Win^.SetMinSize(20,7);
  114.       if not FileOk then
  115.          SetTagging(false);
  116.       Go;
  117.       Done;
  118.    end;
  119.    ItemList.Done;
  120. end.
  121.  
  122.  
  123.